package com.slj.controller;

import com.slj.comm.responce.R;
import com.slj.model.dto.UserDTO;
import com.slj.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 人员表 前端控制器
 * </p>
 *
 * @author 礼俊
 * @since 2025-10-22 10:20
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    //删除小组人员
    @PostMapping("/delete/{userId}")
    @Operation(summary = "删除小组人员")
    @Parameter(name = "userId", description = "人员id")
    public R delete(@PathVariable Integer userId) {
        boolean delete = userService.removeById(userId);
        return R.success(delete);
    }

    //新增小组人员
    @PostMapping("/add")
    @Operation(summary = "新增小组人员")
    public R add(@RequestBody UserDTO userDTO) {
        boolean save = userService.save(userDTO);
        return R.success(save);
    }
}
